<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="m" uri="/cutm_tags"%>
<html>
<head>
<title>串联单信息编排</title>
<link rel="stylesheet"
	href="<s:url value="/common/css/ui-lightness/ui.datepicker.css"/>"
	type="text/css" />
<script type="text/javascript"
	src="<s:url value="/common/script/ui.datepicker.js"/>"></script>
<script type="text/javascript"
	src="<s:url value="/common/script/ui.datepicker-fr.js"/>"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#editForm").vaildAjax(function(data){
		BaseJs.alert('保存成功！');
		BaseJs.setReadonly();
		$('#save').hide();
	});
});
//提交
function commit(){
	if(BaseJs.confirm('确定要提交吗？')){
		var contentInfo = '';
		$('.content').each(function(){
			var voId = $(this).find('.voId').val();
			var title = $(this).find('.title').val();
			var timeLong = $(this).find('.timeLong').val();
			var kouBo = $(this).find('#dropkouBo').attr('list');
			var daoYu = $(this).find('#dropdaoYu').attr('list');
			var bianHouYu = $(this).find('#dropbianHouYu').attr('list');
			var tiYao = $(this).find('.tiYao').val();
			var jiaoBiao = $(this).find('.jiaoBiao').val();
			contentInfo += voId+'|'+title+'|'+timeLong+'|'+kouBo+'|'+daoYu+'|'+bianHouYu+'|'+tiYao+'|'+(jiaoBiao==''?' ':jiaoBiao)+';';
		});
		//alert(contentInfo);
		$('#contentInfo').val(contentInfo);
		$('#editForm').submit();
	}
}
//删除一行
function del(dela){
	if(BaseJs.confirm('确定要提交吗？')){
		$(dela).parent().parent().remove();
	}
}

function getInfor() {
	var pdate = $('input[name=programming.date]').val();
	var pcolumn = $('select[name=programming.column] option:selected').val();
	//BaseJs.toAction('programming/SearchProgram!searchProgm2GaoJian')+'?programming.date='+pdate+'&programming.column='+pcolumn;
	var url=BaseJs.action('programming/SearchProgram!searchProgm2GaoJian')+'?programming.date='+pdate+'&programming.column='+pcolumn;
	window.open(url);
}
function searchDaoYu() {
	var programId = $('#programId').val();
	if(programId!=''){
		var url=BaseJs.action('programming/SearchProgram!searchDaoYu')+'?programming.id='+programId;
		window.open(url);
	}else{
		 alert('请选择编排的节目');
	}
}
function searchManuscript(manuscriptId) {
	if(manuscriptId!=''){
		var url=BaseJs.action('manuscript/EditManuscript!toEdit')+'?manuscript.id='+manuscriptId+'&readOnly=true';
		window.open(url);
	}else{
		 alert('请选择稿件');
	}
}

function addRow(){
	var tr="<tr  id='0' class='content'><td><input type='hidden' class='voId' value='0' disable='true' /></td>"+
		"<td><input type='textfield' class='title' name='title'/></td>" +
		"<td></td><td></td><td></td>" +
		"<td><input type='textfield' class='timeLong' name='timeLong' size='5'/>秒</td>" +
		"<td></td><td></td><td></td>" +
		"<td><m:imgA img='delete' msg='删除'	onclick='del(this)' />&nbsp;"+
		"<m:imgA img='sortup' msg='上移一行'	onclick='moveUp(this)'/>&nbsp;"+
		"<m:imgA img='sortdown' msg='下移一行'	 onclick='moveDown(this)' /></td></tr>";
	$('#options').append(tr);
}	
	//document.getElementById('options').insertRow(rowId);

//使表格行上移，接收参数为链接对象
function moveUp(_a){
	 //通过链接对象获取表格行的引用
	 var _row=_a.parentNode.parentNode;
	 //如果不是第一行，则与上一行交换顺序
	 if(_row.previousSibling)swapNode(_row,_row.previousSibling);
}
//使表格行下移，接收参数为链接对象
function moveDown(_a){
	 //通过链接对象获取表格行的引用
	 var _row=_a.parentNode.parentNode;
	 //如果不是最后一行，则与下一行交换顺序
	 if(_row.nextSibling)swapNode(_row,_row.nextSibling);
	}
//定义通用的函数交换两个结点的位置
function swapNode(node1,node2){
	 //获取父结点
	 var _parent=node1.parentNode;
	 //获取两个结点的相对位置
	 var _t1=node1.nextSibling;
	 var _t2=node2.nextSibling;
	 //将node2插入到原来node1的位置
	 if(_t1)_parent.insertBefore(node2,_t1);
	 else _parent.appendChild(node2);
	 //将node1插入到原来node2的位置
	 if(_t2)_parent.insertBefore(node1,_t2);
	 else _parent.appendChild(node1);
}
function showkouBoInfo(data) {
	$(this).parent().find('input[name=kouBoId]').val('1,2');
}
function showDaoYuInfo() {
	$(this).parent().find('.daoYushow').text('');
	var str='';
	$(this).parent().find('LABEL.checked').each(function(){
		var txt = $(this).text();
		if(txt!='全选'){
			str+='<sapn class="split">'+txt+'</span>';
		}
	});
	$(this).parent().find('.daoYushow').append(str);
	//$(this).parent().find('.daoYuId').val($('.daoYu').IDCheck('on'));
	$(this).parent().find('.daoYuId').val('3,1');
}
function showBianHouYuInfo() {
	$(this).parent().find('.bianHouYushow').text('');
	var str='';
	$(this).parent().find('LABEL.checked').each(function(){
		var txt = $(this).text();
		if(txt!='全选'){
			str+='<sapn class="split">'+txt+'</span>';
		}
	});
	$(this).parent().find('.bianHouYushow').append(str);
	$(this).parent().find('.bianHouYuId').val('2');
}
</script>
</head>
<body>
<h2 class="title"><span>串联单信息编排</span></h2>
<s:form id="serchForm"
	action="programming/SearchProgram!searchProgm2GaoJian"
	onsubmit="return true">
	<s:hidden name="programming.id" id="programId" />
	<table id="sTable" class="form">
		<tr>
			<th width="20%">*编排日期</th>
			<td width="30%"><m:date name="programming.date"
				cssClass="rule[required]" /></td>
			<th width="20%">*编排栏目</th>
			<td width="30%"><m:select enumType="program.type"
				name="programming.column" cssClass="rule[required]" /></td>
		</tr>
	</table>
	<div class="btnGroup"><input value="查询" type="submit"></div>
</s:form>
<s:form id="editForm" action="programming/EditProgram!editProg2GaoJian">
	<s:hidden name="programming.id" id="programId" />
	<s:hidden name="contentInfo" id="contentInfo" />
	<table width="100%" class="list">
		<tr>
			<th width="3%">序号</th>
			<th width="10%">标题</th>
			<th width="10%">记者</th>
			<th width="10%">撰稿日期</th>
			<th width="10%">配音人员</th>
			<th width="6%">配音长度</th>
			<th width="20%">选择人员</th>
			<th width="14%">提要</th>
			<th width="10%">角标</th>
			<th width="7%">操作</th>
		</tr>

		<tbody id="options">
			<s:iterator value="progm2GaoJians">
				<tr id="${id}" class="content" align="left">
					<td><s:hidden name="id" cssClass="voId" /> <s:property
						value="order" /></td>
					<td align="left"><s:property value="manuscript.title" /></td>
					<td align="left"><s:property value="manuscript.user.name" /></td>
					<td><s:date name="manuscript.createDate"
						format="yyyy-MM-dd HH:mm" /></td>
					<td><s:property value="manuscript.puser.name" /></td>
					<td><s:property value="manuscript.timeLong" /> 秒</td>
					<td><s:if test="!manuscript.adv">
						<table bordercolor="1" width="100%" style="color: #000;">
							<tr>
								<td width="20%">口播</td>
								<td width="80%" class="kouBo" style="color: #000;"><s:if
									test="manuscript.kouBo">
									<m:dropUser multiple="true" showSelected="true" name="kouBo"
										canSelectAll="false" />
								</s:if><s:else>无</s:else></td>
							</tr>
							<tr>
								<td>导语</td>
								<td class="daoYu" style="color: #000;"><s:if
									test="!manuscript.kouBo && manuscript.daoyu!=null && manuscript.daoyu!=''">
									<m:dropUser multiple="true" showSelected="true" name="daoYu"
										canSelectAll="false" />
								</s:if><s:else>无</s:else></td>
							</tr>
							<tr>
								<td>编后语</td>
								<td class="bianHouYu" style="color: #000;"><s:if
									test="!manuscript.kouBo && manuscript.bianhouyu!=null && manuscript.bianhouyu!=''">
									<m:dropUser multiple="true" name="bianHouYu"
										showSelected="true" canSelectAll="false" />
								</s:if><s:else>无</s:else></td>
							</tr>
						</table>
					</s:if></td>

					<td><s:if test="!manuscript.adv">
						<s:textarea name="tiYao" cssClass="tiYao"
							cssStyle="height: 100px;  width:  100%;" />
					</s:if></td>
					<td><s:if test="!manuscript.adv">
						<s:textarea name="jiaoBiao" cssClass="jiaoBiao"
							cssStyle="height: 100px;  width:  100%;" />
					</s:if></td>
					<td><s:if test="!manuscript.adv">
						<m:imgA img="view" msg="查看信息"
							onclick="searchManuscript(${manuscript.id})" />&nbsp;
					</s:if> <s:if test="changeOrder ||manuscript.adv ">
						<m:imgA img="delete" msg="删除" onclick="del(this)" />&nbsp;
						<m:imgA img="sortup" msg="上移一行" onclick="moveUp(this) " />&nbsp;
						<m:imgA img="sortdown" msg=" 下移一行" onclick="moveDown(this)" />
					</s:if></td>
				</tr>
			</s:iterator>
		</tbody>
	</table>
	<div class="btnGroup"><input value="保存" type="button" id="save"
		onClick="commit()"> <input value="添加一行" type="button"
		onclick="addRow()" /> <input value="查看导语" type="button"
		onclick="searchDaoYu();"></div>
</s:form>
</body>
</html>